const app = getApp()
Component({
    properties: {
        // defaultData（父页面传递的数据-就是引用组件的页面）
        defaultData: {
            type: Object,
            value: {
                title: "我是默认标题",
                scan: false,
                navigateBack: false
            }
        }
    },
    data: {
        navBarHeight: app.globalData.navBarHeight,
        menuRight: app.globalData.menuRight,
        menuTop: app.globalData.menuTop,
        menuHeight: app.globalData.menuHeight,
    },
    attached: function() {},
    methods: {
        scan() {
            let that = this
            wx.scanCode({
                onlyFromCamera: true,// 只允许从相机扫码
                scanType: ['qrCode'],
                success(res) {
                    // 扫码成功后  在此处理接下来的逻辑
                    that.triggerEvent('scan',res.result)
                }
            })
        },
        navBack(){
            wx.navigateBack()
        }
    }
})